var express = require('express');
var config = require('./config');
var routes = require('./routes');

var app = express.createServer();

app.configure('development', function() {
    app.use(express.errorHandler({
        dumpExceptions: true,
        showStack: true
    }));
    app.use(express.cookieParser());
    app.use(express.session({
        secret: 'string'
    }));
    app.use(express.static(__dirname + '/public'));
});

app.dynamicHelpers({
    session: function(req, res) {
        return req.session;
    }
});

(function init() {
    routes.index(app);
    routes.authorize(app);
    routes.about(app);
})();

app.listen(config.app.port);
console.log('Listening port: ' + app.address().port);